﻿using FlowDesigner.ExchangeDialog;
using FlowDesigner.Interfacebase;
using FlowDesigner.Listpicker.ListpickerView;
using FlowDesigner.Listpicker.ListpickerViewModel;
using FlowDesigner.Loadinganimation;
using FlowDesigner.View;
using FlowDesigner.ViewModel;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
using Unity;
using Unity.Lifetime;

namespace FlowDesigner
{
    /// <summary>
    /// App.xaml 的交互逻辑
    /// </summary>
    public partial class App : Application
    {

        public IUnityContainer _container;

        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

            // 注册类型
            //Containerfot.Container.container.RegisterType<IBaseDialogViewModel>(new ContainerControlledLifetimeManager()); // 注册模型
            // 创建 MainWindow 并注入依赖
            //Containerfot.Container.container.RegisterType<Loading>(new TransientLifetimeManager());//依赖注入加载对话框
            //Containerfot.Container.container.RegisterType<LoadingBase>(new TransientLifetimeManager());//依赖注入加载对话框

            Containerfot.Container.container.RegisterType<BaseDialog>(new TransientLifetimeManager());
            Containerfot.Container.container.RegisterType<BaseDialogViewModel>(new TransientLifetimeManager()); // 注册视图模型
           
            Containerfot.Container.container.RegisterType<EditflownodeView>(new ContainerControlledLifetimeManager()); // 注册编辑视图
            Containerfot.Container.container.RegisterType<EditflownodeViewModel>(new ContainerControlledLifetimeManager()); // 注册编辑视图模型

            Containerfot.Container.container.RegisterType<TestprocessView>(new ContainerControlledLifetimeManager()); // 注册测试窗口
            Containerfot.Container.container.RegisterType<TestprocessViewModel>(new ContainerControlledLifetimeManager()); // 注册视图模型

            Containerfot.Container.container.RegisterType<SelectEntrantlistview>(new ContainerControlledLifetimeManager()); // 注册录入人窗口
            Containerfot.Container.container.RegisterType<SelectEntrantlistviewModel>(new ContainerControlledLifetimeManager()); // 注册录入人视图模型
            // 在程序的任何地方打印所有窗口信息，检查为什么会有两个窗口
            foreach (var window in App.Current.Windows)
            {
                Console.WriteLine($"Window: {window.GetType().Name}, Visibility: {window.ToString()}");
            }


        }
    }
}
